package cn.itcast.erp.dao.impl;

import cn.itcast.erp.dao.IDepDao;
import cn.itcast.erp.entity.Dep;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;
import java.util.UUID;

@SuppressWarnings("all")
public class DepDao extends BaseDao<Dep> implements IDepDao {

    public DetachedCriteria getDetachedCriteria(Dep dep, Dep dep2, Object param){
        DetachedCriteria criteria = DetachedCriteria.forClass(Dep.class);
        if(dep != null){
            if(StringUtils.isNotEmpty(dep.getName())){
                criteria.add(Restrictions.like("name", dep.getName(),MatchMode.ANYWHERE));
            }
            if(StringUtils.isNotEmpty(dep.getTele())){
                criteria.add(Restrictions.like("tele", dep.getTele(),MatchMode.ANYWHERE));
            }
        }
        return criteria;
    }

}
